<?php
namespace app\superAdmin\controller;
use \think\Controller;
use \think\Db;


class User extends Controller 
{
public function index()
{
  $users = Db::name('user_ck')->select();
  $this->assign("userList",$users);
  return $this->fetch();;
}
public function shield($id){

  $ustatenum=Db::name("user_ck")->where("uid='$id'")->value('ustate');

  if($ustatenum==0){
    if (Db::name("user_ck")->where("uid='$id'")->update(['ustate'=>1])) {
      $this->success('解除屏蔽成功');
    }else{
      $this->error('解除屏蔽失败');
    }

  }
  else{
    if (Db::name("user_ck")->where("uid='$id'")->update(['ustate'=>0])) {
      $this->success('屏蔽成功');
    }else{
      $this->error('屏蔽失败');
    }    
  }


}
public function resetpassword($id){
  if(Db::name("user_ck")->where("uid='$id'")->update(['upassword'=>md5('0000000')])){
    $this->success('重置密码成功');
  }
  else{
    $this->error('重置密码失败');
  }

}
public function find(){
  $findid=input('findid');
  $findstate=input('findstate');
  $findphone=input('findphone');

  if ($findid!=NULL) {
    $registration=Db::query("select * from `user_ck` where uid='$findid'");
    $this->assign("userList",$registration);
    return $this->fetch("index");
  }elseif ($findstate!=NULL) {
    $registration=Db::query("select * from `user_ck` where ustate='$findstate'");
    $this->assign("userList",$registration);
    return $this->fetch("index");
  }elseif ($findphone!=NULL) {
    $registration=Db::query("select * from `user_ck` where uphone='$findphone'");
    $this->assign("userList",$registration);
    return $this->fetch("index");
  }else{
    $registration=Db::query("select * from `user_ck`");
    $this->assign("userList",$registration);
    return $this->fetch("index");
  }
}

}